<template>
	<view class="home">
<!-- 		<div v-html="content"></div> -->

		<div class="content">
			<button type="primary" @click="login()">登录/注册</button>
		</div>
	</view>
</template>

<script lang="ts">
	import { uiCollection } from '../../Providing/uiCollection';
	import { request } from '../../Providing/request'
	import { globalVariable } from '../../globalVariable/globalVariable';
	

	export default {

		data() {
			return {
			};
		},
		methods: {
			
			login() {
				uiCollection.showLoading('请将身份证放置在下方读卡处');
	const plugin = uni.requireNativePlugin('getIdCardInformation');

				plugin.sayHi("lance",  (res)=> {
					uiCollection.hideLoading()
					console.log("插件返回内容", JSON.stringify(res))
					if (res['status'] == "err") {
						uiCollection.showToast(res['msg'])
						return
					}

					uiCollection.showLoading("进行身份验证中");
					new request().getHealthCard(res['iDCard']).then((res) => {
						uiCollection.hideLoading();
						console.log(JSON.stringify(res));
						globalVariable.brid = res['brid']
						globalVariable.cardId = res['id']
						globalVariable.realName = res['realName']
						uni.$emit('goToMenuList')
					}).catch((err) => {
						uiCollection.hideLoading();
						console.log('返回err', err);
						uiCollection.showModal(err).then((res1) => {
							if (res1) {
					
					
								//读取身份证返回接口需要使用
								globalVariable.peopleName = res['peopleName'];
								globalVariable.sex = res['sex'];
								globalVariable.people = res['people'];
								globalVariable.birthDay = res['birthDay'];
								globalVariable.addr = res['addr'];
								globalVariable.iDCard = res['iDCard'];
								uni.$emit('goToHealthCardRegistration')


							};
						})
					})

				})
				/**
				 * 需添加读卡操作
				 * */


			}
		
		},

		created() {
			console.log("进入home页")
		},

	}
</script>

<style lang="scss">
	.home {




		.content {
			width: 100%;
			height: 800px;
			background-image: url("../../static/base_image.png");
			background-size: 100% 100%;

			button {
				width: 220px;
				height: 60px;
				font-size: 28px;
				line-height: 60px;
				margin: auto;
				text-align: center;
				background: #fc5531;
				border-radius: 10px;
				color: #fff;
				top: 210px;
			}
		}

	}
</style>